import type { RouteRecordRaw } from 'vue-router';
import { PlatformContext } from './services/PlatformContext';
import type {ICommandService} from '../../core/commands/command.type'

const Analysis = () => import('./view/Analysis.vue')

function testCmd(param: string, param2: number) : string {
  return param + param2;
}


export default {
  registerRoutes: (): RouteRecordRaw[] => [
    {
      path: 'analysis',
      children: [
        {
          path: 'analysis',
          name: 'Analysis',
          components: {
            default: Analysis
          },
          meta: {
            title: '分析模块',
            sidebarVisible: false
          }
        },
      ]
    }
  ],


  onMount: (cmdService: ICommandService) => {
    console.log('[分析模块] 已挂载');
    PlatformContext.setCmdService(cmdService);

    cmdService.registerForService('analysis', 'testCmd', 
      (param: string, param2: number) => Promise.resolve(testCmd(param, param2))
    )
  },
  
  onUnmount: () => {
    console.log('[分析模块] 已卸载');
  }
};